Skip to content

Fix/verb event inject id before deserialize#237

Open
ChrisThompsonTLDR wants to merge 19 commits intohirethunk:mainfrom
ChrisThompsonTLDR:fix/verb-event-inject-id-before-deserialize
Open

Fix/verb event inject id before deserialize#237
ChrisThompsonTLDR wants to merge 19 commits intohirethunk:mainfrom
ChrisThompsonTLDR:fix/verb-event-inject-id-before-deserialize

Conversation

@ChrisThompsonTLDR
Copy link
Contributor

This pull request introduces improved handling of event id serialization and deserialization, adds a new configuration option to control this behavior, and enhances type safety in property reflection. It also expands compatibility for several dependencies and adds comprehensive tests to ensure correct event id handling.

Event ID Serialization & Deserialization Improvements:

  • Added a new serialize_event_id configuration option in config/verbs.php to control whether the event id is included in serialized data. By default, it is excluded, and the row's primary key is used as the source of truth for the event id.
  • Updated VerbEvent::event() to always inject the row id into deserialized events, ensuring correct deserialization even when the stored data lacks an id or contains a stale value.
  • Adjusted the serializer to respect the new serialize_event_id config, excluding or including id as appropriate during serialization.
  • Modified PendingEvent::hydrate() to inject a generated id if missing when hydrating new events.

Type Safety and Reflection Enhancements:

  • Improved property type handling in EventStateRegistry and NormalizeToPropertiesAndClassName by explicitly checking for ReflectionNamedType and ensuring nullability is handled safely. [1] [2] [3] [4]

Dependency Compatibility:

  • Expanded supported versions for illuminate/contracts and laravel/prompts in composer.json for broader Laravel compatibility.

Testing:

  • Added a new test file VerbEventDeserializesWithoutIdInDataTest.php to verify correct event deserialization when id is missing or stale in stored data and to confirm serialization behavior with the new config option.

Documentation:

  • Improved comments and documentation in configuration and code to clarify the reasoning and effects of the new serialize_event_id option and related logic. [1] [2]

ChrisThompsonTLDR and others added 19 commits February 11, 2026 04:24
Serializer excludes Event::id during serialization (IGNORED_ATTRIBUTES)
but SerializedByVerbs events require it for deserialization. Merge the
verb_events row id into the data so the event reconstructs with the
correct id instead of failing or generating a new one.
Fixes FsmTransitioned deserialization error when firing with named args -
Events require an id but we don't have one yet when creating fresh.
…ies with union types

ReflectionUnionType (e.g. FsmStateEnum|string|null) does not have isBuiltin() or
getName() - only ReflectionNamedType does. Guard with instanceof before calling.
…llProperties

ReflectionUnionType does not have getName() - only ReflectionNamedType does.
Guard with instanceof before calling; union-typed properties cannot be State.
…ReflectionUnionType

Updated the EventStateRegistry class to handle ReflectionIntersectionType and ReflectionUnionType correctly. Added necessary guards to prevent errors when dealing with union-typed properties in the findAllProperties method. This improves the robustness of state discovery for events.
Co-authored-by: Cursor <cursoragent@cursor.com>
…es - not needed for event ID fix

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant